﻿CREATE FUNCTION dbo.NLin_NSIService
	(
	@ID int
	)
RETURNS int
AS
	BEGIN
	DECLARE @linksCount int
	
	SELECT @linksCount = COUNT(ID) FROM PAY_IN_ON_SERVICE WHERE NSI_SERVICE_ID = @ID
	
	SELECT @linksCount = @linksCount + COUNT(ID) FROM VAT_INV_ON_SERVICE WHERE NSI_SERVICE_ID = @ID
	
	RETURN @linksCount
	END
